#!/usr/bin/make -f
export DH_VERBOSE = 1

BUILDDIR = build

build:
	mkdir $(BUILDDIR);
	cd $(BUILDDIR); cmake @CMAKE_ENVIRONMENT@ -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr ..
	make -j4 -C $(BUILDDIR)

binary: binary-indep binary-arch

binary-indep:

binary-arch:
	cd $(BUILDDIR); cmake -P cmake_install.cmake
	rm -rf debian/tmp/usr/include debian/tmp/usr/lib debian/tmp/usr/bin/flatc
	mkdir debian/tmp/DEBIAN
	cp cmake/package-scripts/postinst debian/tmp/DEBIAN
	chmod 0775 debian/tmp/DEBIAN/postinst
	cp cmake/package-scripts/preinst debian/tmp/DEBIAN
	chmod 0775 debian/tmp/DEBIAN/preinst
	cp cmake/package-scripts/prerm debian/tmp/DEBIAN
	chmod 0775 debian/tmp/DEBIAN/prerm
	dpkg-gencontrol -phyperion
	dpkg --build debian/tmp ..
	rm -rf debian/tmp $(BUILDDIR)

clean:
	rm -rf $(BUILDDIR)

.PHONY: build binary binary-arch binary-indep clean
